﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace RCCM
{
    public partial class RCCM : Form
    {
        private Dictionary<string, RCCMModel> dic;
        public RCCM()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            dic = new Dictionary<string, RCCMModel>();
            string text = Properties.Resources.all;
            string[] lines = text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string item in lines)
            {
                string[] info = item.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

                RCCMModel rCCMModel = new RCCMModel();

                rCCMModel.Name = info[0];
                rCCMModel.Spec = info[1];
                rCCMModel.Size = info[2];
                rCCMModel.Types = info[3];
                rCCMModel.Chinese = info[4];
                if (!dic.ContainsKey(rCCMModel.Name))
                {
                    dic.Add(rCCMModel.Name, rCCMModel);
                }

            }
            labMessage.Text = "准备完毕";
            labChi.Text = "";
            labSize.Text = "";
            labSpec.Text = "";
            labType.Text = "";
        }

        private void txtInput_MouseClick(object sender, MouseEventArgs e)
        {
            txtInput.Clear();
            labMessage.Text = "按回车键搜索";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string seachValue = txtInput.Text.Replace(" ", "").ToUpper();
            if (dic.ContainsKey(seachValue))
            {
                RCCMModel rCCMModel = dic[seachValue];
                labChi.Text = rCCMModel.Chinese;
                labSize.Text = rCCMModel.Size;
                labSpec.Text = rCCMModel.Spec;
                labType.Text = rCCMModel.Types;

                labMessage.Text = "";
            }
            else
            {
                labChi.Text = "";
                labSize.Text = "";
                labSpec.Text = "";
                labType.Text = "";
                labMessage.Text = "数据不存在";
            }
        }
    }
}
